package com.lg.product.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lg.product.entity.Spu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * spu表，该表描述的是一个抽象性的商品，比如 iphone8 Mapper 接口
 * </p>
 *
 * @author song
 * @since 2020-07-22
 */
public interface SpuMapper extends BaseMapper<Spu> {
    IPage<Spu> listSpu(Spu spu , Page page);
    //修改上架 下架
    @Select("UPDATE tb_spu SET saleable=#{saleable}  WHERE id=#{id}")
    Long updateSaleable(@Param("id") Long id,@Param("saleable") Integer saleable);

    @Select("SELECT * from tb_spu s LEFT JOIN tb_spu_detail d on s.id=d.spu_id WHERE s.id=#{id}")
    Spu listById(Long id);
}
